#         selectFrame = Frame(pFrame)
#         self.topProtocolIsolateIntVar = IntVar()
#         check = Checkbutton(selectFrame,
#                             variable=self.topProtocolIsolateIntVar,
#                             command=self.set_top_protocol_isolate_checkbutton)
#         check.pack(side=LEFT)
#         self.topProtocolNameTextVar = StringVar()
#         self.topProtocolEntry = entry = Entry(
#             selectFrame,width=10,
#             #state=DISABLED,
#             textvariable=self.topProtocolNameTextVar,
#             )
#         entry.bind('<Return>',self.set_top_protocol_name_entry)
#         entry.pack(side=LEFT,fill=X,expand=1)
#         self.topProtocolColorButton = button = Button(
#             selectFrame,text='Color',
#             command=self.set_top_protocol_color_button_click
#             )
#         button.pack(side=LEFT)
#         selectFrame.pack(side=BOTTOM,fill=X,expand=1)


    def addGraphedProtocolFilter(self,port):
        graphedFilter = self.getGraphedProtocols()
        if port not in graphedFilter:
            graphedFilter.append(port)
    def refreshGraphedProtocols(self):
        # make sure that all isolated protocols are being graphed
        print 'Refreshing Graphed Protocols'
        self.current['filter']['graph']['protocols'] = []
        graphed = self.getGraphedProtocols()
        print 'Graphed protocols:',self.getGraphedProtocols()
        for port in self.getIsolatedProtocols():
            if port not in graphed:
                print 'Adding ',port,'to graphed protocols'
                self.addGraphedProtocolFilter(port)
        print 'Graphed protocols:',self.getGraphedProtocols()
    def refreshIsolatedProtocols(self):
        pass
    def addProtocolIsolateFilter(self,port):
        self.tagProtocolAsImportant(port)
        protocolFilter = self.getIsolatedProtocols()
        if port not in protocolFilter:
            protocolFilter.append(port)
        self.refreshProtocols()
    def removeProtocolIsolateFilter(self,port):
        self.tagProtocolAsImportant(port)
        protocolFilter = self.getIsolatedProtocols()
        if port in protocolFilter:
            protocolFilter.remove(port)
        self.refreshProtocols()
    def getIsolatedProtocols(self):
        return self.current['filter']['isolate']['protocols']
    def getGraphedProtocols(self):
        return self.current['filter']['graph']['protocols']
    def getIsolatedTalkers(self):
        return self.current['filter']['isolate']['talkers']
    def getGraphedTalkers(self):
        return self.current['filter']['graph']['talkers']
    def getIsolatedListeners(self):
        return self.current['filter']['isolate']['listeners']
    def getGraphedListeners(self):
        return self.current['filter']['graph']['listeners']
    def isProtocolIsolated(self,port):
        protocolFilter = self.getIsolatedProtocols()
        return port in protocolFilter
    def isProtocolGraphed(self,port):
        protocolFilter = self.getGraphedProtocols()
        return port in protocolFilter
    def isTalkerIsolated(self,ip,octets=4):
        talkerFilter = self.getIsolatedTalkers()
        return ip[:octets] in talkerFilter
    def isTalkerGraphed(self,ip,octets=4):
        talkerFilter = self.getGraphedTalkers()
        return ip[:octets] in talkerFilter
    def isListenerIsolated(self,ip,octets=4):
        listenerFilter = self.getIsolatedListeners()
        return ip[:octets] in listenerFilter
    def isListenerGraphed(self,ip,octets=4):
        listenerFilter = self.getGraphedListeners()
        return ip[:octets] in talkerFilter

###################################
    def get_mod_pack(self,parent,isolateFunc,nameFunc,colorFunc):
        pack = {}
        selectFrame = pack['frame'] = Frame(parent)
        
        pack['isolate'] = IntVar()
        check = pack['checkButton'] = Checkbutton(
            selectFrame,
            variable=pack['isolate'],
            command=isolateFunc
            )
        check.pack(side=LEFT)
        pack['name'] = StringVar()
        pack['nameEntry'] = entry = Entry(
            selectFrame,
            #width=10,
            #state=DISABLED,
            textvariable=pack['name'],
            )
        entry.bind('<Return>',nameFunc)
        entry.pack(side=LEFT,fill=X,expand=1)
        pack['colorButton'] = button = Button(
            selectFrame,
            text='Color',
            command=colorFunc,
            )
        button.pack(side=LEFT)
        selectFrame.pack(side=BOTTOM,fill=X,expand=1)
        return pack
    def set_top_protocol_isolate_checkbutton(self):
        port = self.getSelectedTopProtocol()
        if (port is not None):
            if self.topProtocolPack['isolate'].get():
            #if self.topProtocolIsolateIntVar.get():
                print 'setting protocol isolate:',port
                self.addProtocolIsolateFilter(port)
            else:
                print 'removing protocol isolate:',port
                self.removeProtocolIsolateFilter(port)
    def set_top_protocol_name_entry(self,event):
        port = self.getSelectedTopProtocol()
        if port is not None:
            name = self.topProtocolPack['name'].get()
            #name = self.topProtocolNameTextVar.get()
            self.setImportantProtocolName(port,name)
        self.refreshProtocols()
        self.resetTopProtocolsList()
#####################################
#         self.topProtocolPack = self.get_mod_pack(
#             pFrame,
#             self.set_top_protocol_isolate_checkbutton,
#             self.set_top_protocol_name_entry,
#             self.set_top_protocol_color_button_click,
#             )
    
